import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { ServiceBasic } from '../../kalend';

@Injectable()
export class PlatformuserService extends ServiceBasic {

  constructor(http: Http) {
    super('/puser', http);
  }

  login(account: string, password: string): Promise<any> {
    const param = { phone: account, password: password };
    return this.httppost('/login', param);
  }
  query(doc: any) {
    return this.httppost(`/query`, doc);
  }
  /**查询单条信息 */
  queryById(id: any) {
    return this.httpget(`/queryById/${id}`);
  }
  /**禁用 */
  lock(id: any) {
    return this.httpget(`/lock/${id}`);
  }
  /**启用 */
  open(id: any) {
    return this.httpget(`/open/${id}`);
  }
  update(doc: any) {
    if (doc._id) {
      /**修改用户信息 */
      return this.httppost('/update', doc);
    } else {
      /**新增用户 */
      return this.httppost('/create', doc);
    }
  }
  getuser(type: any, mid: any) {
    return this.httppost(`/getuser`, { type: type, mid: mid });
  }

  getcustomeruser(doc) {
    return this.httppost(`/getcustomeruser`, doc);
  }

  getSingleUser(doc) {
    return this.httppost(`/getSingleUser`, doc);
  }

  updateuserpwd(doc) {
    return this.httppost(`/updatepwd`, doc);
  }

  editPass(doc: any) {
    return this.httppost(`/editPass`, doc);
  }
}
